package com.pkx.guide.record.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.pkx.guide.common.annotation.Log;
import com.pkx.guide.common.annotation.ORpose;
import com.pkx.guide.common.enums.BusinessType;
import com.pkx.guide.record.entity.ModifyHistoryDTO;
import com.pkx.guide.record.entity.TRecordGuidePublish;
import com.pkx.guide.record.service.TRecordGuidePublishService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 诱导屏发布记录表 控制器
 *
 * @author sunsy
 * @since 2023-11-14
 */
@RestController
@RequestMapping("/record/publish")
@Tag(name = "诱导屏发布记录表")
@Slf4j
@ORpose
public class TRecordGuidePublishController {

    @Autowired
    private TRecordGuidePublishService tRecordGuidePublishService;

    @Operation(summary = "诱导屏发布记录表分页列表")
    @GetMapping("/page")
    public IPage<TRecordGuidePublish> page(Page page, TRecordGuidePublish tRecordGuidePublish) {
        return tRecordGuidePublishService.pageList(page,tRecordGuidePublish);
    }

    @Operation(summary = "诱导屏发布记录表列表")
    @GetMapping("/list")
    public List<TRecordGuidePublish> list(TRecordGuidePublish tRecordGuidePublish) {
        return tRecordGuidePublishService.listByEntity(tRecordGuidePublish);
    }

    @Operation(summary = "诱导屏发布记录表详情")
    @GetMapping(value = "/{id}")
    public TRecordGuidePublish selectById(@PathVariable("id") Integer id) {
        return tRecordGuidePublishService.selectById(id);
    }

    @Operation(summary = "诱导屏发布记录表新增")
    @PostMapping("/")
    @Log(title = "诱导屏发布记录表", businessType = BusinessType.INSERT)
    public Boolean add(@RequestBody TRecordGuidePublish tRecordGuidePublish) {
        return tRecordGuidePublishService.saveTRecordGuidePublish(tRecordGuidePublish);
    }

    @Operation(summary = "诱导屏发布记录表修改")
    @PutMapping("/")
    @Log(title = "诱导屏发布记录表", businessType = BusinessType.UPDATE)
    public Boolean modify(@RequestBody TRecordGuidePublish tRecordGuidePublish) {
        return tRecordGuidePublishService.modify(tRecordGuidePublish);
    }

    @Operation(summary = "诱导屏发布记录表删除(单个条目)")
    @DeleteMapping(value = "/{id}")
    @Log(title = "诱导屏发布记录表", businessType = BusinessType.DELETE)
    public Boolean deleteById(@PathVariable("id") Integer id) {
        return tRecordGuidePublishService.deleteById(id);
    }

    @Operation(summary = "发布历史修改")
    @PutMapping("/modifyHistory")
    @Log(title = "诱导屏发布记录表", businessType = BusinessType.UPDATE)
    public Boolean modifyHistory(@RequestBody ModifyHistoryDTO modifyHistoryDTO) {
        return   tRecordGuidePublishService.modifyByPathParam(modifyHistoryDTO);
    }

}
